package cn.prototype.csl;

/**
 * Created by siyuzhiyue on 2017/6/13.
 */
public class PrototypePatternDemo {
    public static void main(String[] args) {
        ShapeCache.loadCache();

        Shape clonedShape = ShapeCache.getShape("1");
        System.out.println("Shape : " + clonedShape.getType());

        Shape clonedShape2 = ShapeCache.getShape("2");
        System.out.println("Shape : " + clonedShape2.getType());

        Shape clonedShape3 = ShapeCache.getShape("3");
        System.out.println("Shape : " + clonedShape3.getType());

        Circle circle = new Circle();
        NewShape newShape = new NewShape();
        newShape.shape = circle;

        NewShape copyShape = (NewShape) newShape.clone();
        copyShape.setShape(new Square());

        System.out.println(newShape.getShape().getType());
        System.out.println(copyShape.getShape().getType());

    }
}
